﻿using Volo.Abp.Application.Services;
using Common.Security;
using Ecommerce.DTO;
using Ecommerce.tbUser;
using System;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;

namespace Ecommerce
{
    public class UserMySelfService : ApplicationService,IUserServices
    {
        private readonly IRepository<User, Guid> _users;

        public UserMySelfService(IRepository<User, Guid> users)
        {
            _users = users;
        }

        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task<int> AddUser(CreateUpdateUserDto dto)
        {
            dto.UserPwd = Md5.GetMd5(dto.UserPwd);
            dto.UserName = "游客";
            var a = ObjectMapper.Map<CreateUpdateUserDto, User>(dto);
            await _users.InsertAsync(a);
            return 1;
        }

    }
}
